<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
<xsl:output method="html"/>
    
    <xsl:param name="URL"/>
    
    <xsl:template match="/">
        <xsl:apply-templates select="*" mode="index"/>
        <xsl:apply-templates select="*" mode="content"/>
    </xsl:template>
    
    <!-- Create Index -->
    <xsl:template match="bookByAuthor" mode="index">
        <xsl:document href="index.html">
            <html>
                <head>
                    <ttile> Books By Authors</ttile>
                </head>
                <body bgcolor="#FFFFFF" text="#000000">
                    <h1>Books by authors</h1>
                    <xsl:apply-templates mode="index"/>
                </body>
            </html>
        </xsl:document>
    </xsl:template>
    
    <xsl:template match="author" mode="index">
        <h2>
            <a href="{concat($URL,@author,'.html')}">
                <xsl:value-of select="@author"/>
            </a>
        </h2>
    </xsl:template>
    
    <xsl:template match="author" mode="content">
        <xsl:document href="{concat(@author,'.html')}">
            <html>
                <head>
                    <title><xsl:value-of select="@author"/></title>
                </head>
                <body bgcolor="#FFFFFF" text="#000000">
                    <h1><xsl:value-of select="@author"/>Books</h1>
                    <table border="1" cellpadding="3">
                        <tbody>
                            <tr>
                                <th>
                                    BookSales
                                </th>
                                <th>
                                    In US
                                </th>
                            </tr>
                            <xsl:apply-templates mode="content"/>
                              
                        </tbody>
                    </table>
                    
                    <h2><a href="{concat($URL,'index.html')}">Home</a></h2>
                    
                    </body>
                
            </html>
        </xsl:document>
    </xsl:template>
    <xsl:template match="book" mode="content">
        <tr>
            <td><xsl:value-of select="@title"/>
            </td>
            <td><xsl:value-of select="@price"/></td>
        </tr>
        
    </xsl:template>
</xsl:stylesheet>